package com.xszx.business.controller.admin;

import com.xszx.server.dto.AjaxJson;
import com.xszx.server.dto.Page;
import com.xszx.server.entity.${Domain};
import com.xszx.server.service.${Domain}Service;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/${domain}")
public class ${Domain}Controller {
    @Resource
    private ${Domain}Service ${domain}Service;

    @PostMapping("/getAll${Domain}s")
    public Page getAll${Domain}s(@RequestBody Page page){
        return ${domain}Service.getAll${Domain}s(page);
    }

    @GetMapping("/get${Domain}")
    public AjaxJson get${Domain}(String id){
        return AjaxJson.success().put("${domain}s",${domain}Service.get${Domain}(id));
    }

    @PostMapping("/save")
    public AjaxJson save(@RequestBody ${Domain} ${domain}){
        return AjaxJson.success(${domain}Service.saveOrUpdate(${domain}));
    }
    @GetMapping("/delete${Domain}")
    public AjaxJson delete${Domain}(String id){
        int result = ${domain}Service.del(id);
        if(result>0){
            return AjaxJson.success("删除成功");
        }else{
            return AjaxJson.error("删除失败");
        }
    }
}
